Skip to content

feat(@angular/build): Support splitting browser and server stats jsonfiles for easier consumption#32989

Closed
tsteuwer-accesso wants to merge 82 commits into
angular:mainfrom
tsteuwer-accesso:main
Closed

feat(@angular/build): Support splitting browser and server stats jsonfiles for easier consumption#32989
tsteuwer-accesso wants to merge 82 commits into
angular:mainfrom
tsteuwer-accesso:main

Conversation

@tsteuwer-accesso
Copy link
Copy Markdown

@tsteuwer-accesso tsteuwer-accesso commented Apr 12, 2026

This feature supports splitting out the browser and server stats json files so it's easier to inspect the bundle in various analyzers. Today, everything gets dumped into a single file and it's nearly impossible to use without hours of fix -> remove unused browser/server chunks -> analyze and starting the loop all over again.

This feature implements the feature request I made in #28185, along with another developers request to see a stats json file for just the initial page bundle. I've tested this out in my own repository and it's already helped an incredible amount.

Fixes #28185 #28671

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

When using --stats-json, the CLI outputs a single stats.json file.

Issue Number: #28185

What is the new behavior?

We now receive a browser-stats.json, server-stats.json, browser-initial-stats.json and server-initial-stats.json

Does this PR introduce a breaking change?

  • Yes
  • No

This is a breaking change for anyone relying on CI processes that inspect the old stats.json file as it will no longer be named that.

Other information

@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: @angular/build labels Apr 12, 2026
@tsteuwer-accesso
Copy link
Copy Markdown
Author

@alan-agius4 , made the requested changes. Let me know if there's anything else.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the build process to generate separate and filtered stats files for browser and server outputs, replacing the single stats.json with more granular files like browser-stats.json and browser-initial-stats.json. The changes include updates to the application builder, esbuild bundling context, and Webpack configuration. Feedback highlights an opportunity to refactor the metafile filtering logic into a shared utility to reduce code duplication. Additionally, it was noted that the Webpack implementation currently produces a duplicate file for initial stats instead of a filtered one, which should be addressed to ensure feature parity with the esbuild implementation.

Comment thread packages/angular/build/src/builders/application/execute-build.ts Outdated
Comment thread packages/angular_devkit/build_angular/src/tools/webpack/configs/common.ts Outdated
Copy link
Copy Markdown
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. Please see the comments. In addition please rebase and squash your commits.

Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts
Comment thread packages/angular/build/src/builders/application/execute-build.ts
Comment thread packages/angular/build/src/builders/application/execute-build.ts Outdated
@alan-agius4 alan-agius4 added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews target: minor This PR is targeted for the next minor release labels Apr 14, 2026
Comment thread packages/angular/build/src/tools/esbuild/bundler-context.ts
Comment thread packages/angular/build/src/builders/application/chunk-optimizer.ts Outdated
@tsteuwer-accesso
Copy link
Copy Markdown
Author

Thanks @alan-agius4 , looking into this.

@tsteuwer-accesso
Copy link
Copy Markdown
Author

@alan-agius4 , I've changed this per your review.

When I was creating the unit tests files, I can't import Metafile from esbuild. I kept getting an error stating that No explicit Bazel dependency for this module. Do you know how I can fix this so I don't have to make types for a Metafile or use the hack of Parameters[0] to get the Metafile type?

…asier consumption

Adds separate `browser-stats.json` and `server-stats.json` output files alongside the existing `stats.json`, making it easier for consumers to work with browser-only or server-only bundle metadata. Includes unit tests for the new filtering utility and the updated stats-json builder option.
@tsteuwer-accesso
Copy link
Copy Markdown
Author

@alan-agius4 any update on this?

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels May 13, 2026
angular-robot and others added 12 commits May 16, 2026 08:39
See associated pull request for more information.
This test ensures that stack traces map correctly to source files and that coverage reports are generated when running Vitest in browser mode with coverage enabled. This provides validation for the current implementation and will help verify future refactors removing the source-map-support dependency.
This change removes the injection of `source-map-support` in Vitest browser tests and enables sourcemap rebasing for coverage runs as well. This allows Vitest's native remapper to handle stack traces and coverage correctly without needing the external polyfill in the browser. The E2E tests have been verified to pass with these changes. The unused `createSourcemapSupportPlugin` function has also been removed.
See associated pull request for more information.
See associated pull request for more information.
Adds a new schematic migration to automatically add trustProxyHeaders configuration to server.ts files in workspaces where either AngularNodeAppEngine or AngularAppEngine are used.
…base rule

Remove the `find_examples` tool from the Angular CLI MCP server, along with the `ng_examples_db`
Bazel rule and associated example files. With the availability of the official Angular developer
skills repository (https://github.com/angular/skills), this local database lookup tool is redundant.
Reduce maintenance overhead and simplify the codebase by eliminating the need to maintain a local
SQLite database of examples within the CLI repository.
See associated pull request for more information.
See associated pull request for more information.
alan-agius4 and others added 17 commits May 16, 2026 08:39
Removes the stateful `/g` flag from `URL_PARAMETER_REGEXP`. Previously, calling `.test()` on the global regular expression advanced its internal `lastIndex` property. This caused subsequent evaluations in the route extraction pipeline to silently fail to match, skipping `getPrerenderParams` for parameterized routes.

Closes #33154
This should have been done by the release process but it failed.
…r usage

Removes the last usage of `createConsoleLogger` in the repository from
the webpack builder tests. This makes the test consistent with others
in the file and allows for potential removal of the function.

Also removes an unused `BuildResult` import in the same file.
`createConsoleLogger` is deprecated. Use a custom logger implementation instead. This does not apply to application code.
See associated pull request for more information.
See associated pull request for more information.
…eaders is true

Previously, setting `trustProxyHeaders: true` only allowed a predefined set of common proxy headers (such as `x-forwarded-for` and `x-forwarded-host`). This resulted in warning logs when requests contained other valid proxy headers like `x-forwarded-client-cert` or `x-forwarded-email`.
…ureSupport

The `target` parameter in the `getFeatureSupport` function is no longer used internally, so it has been removed to simplify the function signature and call sites.
Unlike ng_package doesn't add these fields.
Virtual files generated by esbuild for disabled browser fields leak into the
watch list, causing spurious rebuilds in watch mode.

Previously, only paths where the suffix was a Node.js builtin module were
ignored. Now, any path containing `(disabled):` is ignored as it represents
a virtual file that doesn't exist on disk.

Fixes #33160
…actor-jasmine-vitest

The `refactor-jasmine-vitest` schematic fails to remove `.args` when migrating
`spy.calls.all()[i].args`, resulting in uncompilable code in Vitest.

Now, a specialized transformer detects `spy.calls.all()[i].args` and transforms
it to `vi.mocked(spy).mock.calls[i]`, removing the unnecessary `.args` property
access.

Fixes #33112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--stats-json to allow giving stats to both server and browser, separately

8 participants